#include <iostream>
#include <string>
#include "HardDisk.h"

using namespace std;


HardDisk::HardDisk(string ID, string size, bool isPortable, string Brand, int stock, int price):Product(ID, Brand, stock, price){
	this->size = size;
	this->isPortable = isPortable;
}

map <int, string> HardDisk::getHeader(){
	map <int, string> result;
	result[0] = "ID";
	result[1] = "Memory Size";
	result[2] = "Portable";
	result[3] = "Brand";
	result[4] = "Stock";
	result[5] = "Price";
	return result;
}

map <int, int> HardDisk::getHeaderLength(){
	map <int, int> result;
	result[0] = 10;
	result[1] = 13;
	result[2] = 10;
	result[3] = 15;
	result[4] = 7;
	result[5] = 7;
	return result;
}

map <int, string> HardDisk::getAllData(){
	map <int, string> result;
	result[0] = id;
	result[1] = size;
	result[2] = isPortable?"Yes":"No";
	result[3] = brand;
	result[4] = int2str(stock);
	result[5] = int2str(price);
	return result;
}

bool HardDisk::isLarger(int compareFactor, Product *product2){
	HardDisk *hardDisk = dynamic_cast < HardDisk * >(product2);

	//remark: if(hardDisk != 0) is insert for safety reason. It won't be false under proper communication between classes

	switch (compareFactor){
	case 0:
		return !product2->Product::isLarger(compareFactor, this);
	case 1: //compare by memory size
		if(hardDisk != 0){
			return this->size.compare(hardDisk->size) > 0;;
		}
	case 2: //compare by portability
		if(hardDisk != 0){
			return this->isPortable > hardDisk->isPortable;
		}
	default: //call parent comparason
		return !product2->Product::isLarger(compareFactor-2, this);
	}
}